//
//  TitleCellData.m
//  18Birdies
//
//  Created by Lc on 15/4/2.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import "LcFoundation.h"
#import "OneLabelWithIndicateCell.h"
#import "OneLabelWithIndicateCellData.h"

@implementation OneLabelWithIndicateCellData

+ (OneLabelWithIndicateCellData*)cellDataWithTitle:(NSString*)title {
  return [self cellDataWithTitle:title
                          lcFont:LcFont.gr14
               indicateImageName:nil
        onIndicateClickedHandler:nil
            onCellClickedHandler:nil];
}

+ (OneLabelWithIndicateCellData*)cellDataWithTitle:(NSString*)title
                                            lcFont:(LcFont*)lcFont
                                  onClickedHandler:(OnCellClickedHanlder)onClickedHandler {
  return [self cellDataWithTitle:title
                          lcFont:lcFont
               indicateImageName:nil
        onIndicateClickedHandler:nil
            onCellClickedHandler:onClickedHandler];
}

+ (OneLabelWithIndicateCellData*)cellDataWithTitle:(NSString*)title
                                 indicateImageName:(NSString*)indicateImageName
                          onIndicateClickedHandler:(OnClickedHandler)indicateClickedHandler
                              onCellClickedHandler:(OnCellClickedHanlder)cellClickedHandler {
  return [self cellDataWithTitle:title
                          lcFont:LcFont.gr14
               indicateImageName:indicateImageName
        onIndicateClickedHandler:indicateClickedHandler
            onCellClickedHandler:cellClickedHandler];
}

+ (OneLabelWithIndicateCellData*)cellDataWithTitle:(NSString*)title
                                            lcFont:(LcFont*)lcFont
                                 indicateImageName:(NSString*)indicateImageName
                          onIndicateClickedHandler:(OnClickedHandler)indicateClickedHandler
                              onCellClickedHandler:(OnCellClickedHanlder)cellClickedHandler {
  LC_CHECK_NOT_EMPTY(title);
  LC_CHECK_NOT_NULL(lcFont);
  OneLabelWithIndicateCellData* cellData = [[self alloc] init];
  cellData->_title = title.copy;
  cellData->_lcFont = lcFont;
  cellData.indicateImageName = indicateImageName;
  cellData.indicateClickedhandler = indicateImageName.length > 0 ? indicateClickedHandler : nil;
  cellData.onCellClickedHandler = cellClickedHandler;
  cellData.clickable = cellClickedHandler != nil;
  return cellData;
}

- (Class)cellClazz {
  return OneLabelWithIndicateCell.class;
}

- (NSString*)nibName {
  return @"OneLabelWithIndicateCell";
}

- (void)refreshCell:(OneLabelWithIndicateCell*)cell {
  [super refreshCell:cell];
  cell.title.text = self.title;
  [cell.title setLcFont:self.lcFont];
  if (self.indicateImageName.length > 0) {
    cell.indicateImageView.image = [UIImage imageNamed:self.indicateImageName];
    cell.indicateImageView.hidden = NO;
  } else {
    cell.indicateImageView.hidden = YES;
  }
  cell.indicateClickedhandler = self.indicateClickedhandler;
  cell.hintImageview.hidden = !self.showHint;
}

@end
